package com.os.pojo.virtualmemory;


import com.os.service.SwapService;
import lombok.Getter;
import lombok.Setter;

/**
 * 一个段
 */
public class Segment implements MemoryBlock {
    /**
     * 使用的pcbid
     */
    public int pcbId;

    /**
     * 段号
     */
    public int id;

    /**
     * 是否已用
     */
    @Getter
    public boolean isUsed;

    /**
     * 物理内存开始地址, 块号 * 块大小
     */
    public int startAdress;

    /**
     * 段的大小，单位，字符
     */
    public int size;

    /**
     * 实际占用内存大小
     */
    public int len;

    /**
     * 对应的页表
     */
    public PageTable pageTable;

    /**
     * 页表置换服务
     */
    public SwapService<Page> pageSwapService;

    @Setter
    @Getter
    public int LRUTime;
    @Setter
    @Getter
    public int FIFOTime;

    @Setter
    public boolean CLOCKBit;

    public Segment() {

    }

    public Segment(int pcbId, int id, int size, int len) {
        this.pcbId = pcbId;
        this.id = id;
        this.isUsed = false;
        this.startAdress = -1;
        this.size = size;
        this.len = len;
    }

    @Override
    public int getId() {
        return id;
    }

    @Override
    public int getSize() {
        return size;
    }

    @Override
    public int getParId() {
        return pcbId;
    }

    @Override
    public boolean getCLOCKBit() {
        return CLOCKBit;
    }


}
